<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Dumps a string representation of an internal zval structure to output</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.boolval.html">« boolval</a></li>
      <li style="float: right;"><a href="function.doubleval.html">doubleval »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.var.html">Variable handling 函数</a></li>
    <li>Dumps a string representation of an internal zval structure to output</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.debug-zval-dump" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">debug_zval_dump</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">debug_zval_dump</span> &mdash; <span class="dc-title">Dumps a string representation of an internal zval structure to output</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.debug-zval-dump-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>debug_zval_dump</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>, <span class="methodparam"><span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span> <code class="parameter">...$values</code></span>): <span class="type"><span class="type void">void</span></span></div>

  <p class="para rdfs-comment">
   Dumps a string representation of an internal zval (Zend value) structure to output.
   This is mostly useful for understanding or debugging implementation details of the
   Zend Engine or PHP extensions.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.debug-zval-dump-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">value</code></dt>

     <dd>

      <p class="para">
       The variable or value to dump.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">values</code></dt>

     <dd>

      <p class="para">
       Further variables or values to dump.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.debug-zval-dump-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.debug-zval-dump-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5269">
    <p><strong>示例 #1 <span class="function"><strong>debug_zval_dump()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$var1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'Hello'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$var1&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">'&nbsp;World'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$var2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$var1</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">debug_zval_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$var1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
string(11) &quot;Hello World&quot; refcount(3)
</pre></div>
    </div>
   </div>
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <strong>Understanding the <code class="literal">refcount</code></strong><br />
   <p class="para">
    The <code class="literal">refcount</code> value shown by this function may be
    surprising without a detailed understanding of the engine&#039;s implementation.
   </p>
   <p class="para">
    The Zend Engine uses reference counting for two different purposes:
   </p>
   <p class="para">
    <ul class="simplelist">
     <li class="member">
      Optimizing memory usage using a technique called &quot;copy on write&quot;,
      where multiple variables holding the same value point to the same copy
      in memory. When any of the variables is modified, it is pointed to a new
      copy in memory, and the reference count on the original is decreased by 1.
     </li>
     <li class="member">
      Tracking variables which have been assigned or passed by reference (see
      <a href="language.references.html" class="link">References Explained</a>). This
      refcount is stored on a separate reference zval, pointing to the zval
      for the current value. This additional zval is not currently shown by
      <span class="function"><strong>debug_zval_dump()</strong></span>.
     </li>
    </ul>
   </p>
   <p class="para">
    Because <span class="function"><strong>debug_zval_dump()</strong></span> takes its input as normal
    parameters, passed by value, the copy on write technique will be used
    to pass them: rather than copying the data, the refcount will be increased
    by one for the lifetime of the function call. If the function modified the
    parameter after receiving it, then a copy would be made; since it does not,
    it will show a refcount one higher than in the calling scope.
   </p>
   <p class="para">
    The parameter passing also prevents <span class="function"><strong>debug_zval_dump()</strong></span>
    showing variables which have been assigned by reference. To illustrate,
    consider a slightly modified version of the above example:
   </p>
   <p class="para">
    <div class="example" id="example-5270">
     
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$var1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'Hello'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$var1&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #DD0000">'&nbsp;World'</span><span style="color: #007700">;<br /></span><span style="color: #FF8000">//&nbsp;Point&nbsp;three&nbsp;variables&nbsp;as&nbsp;references&nbsp;to&nbsp;the&nbsp;same&nbsp;value<br /></span><span style="color: #0000BB">$var2&nbsp;</span><span style="color: #007700">=&amp;&nbsp;</span><span style="color: #0000BB">$var1</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$var3&nbsp;</span><span style="color: #007700">=&amp;&nbsp;</span><span style="color: #0000BB">$var1</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">debug_zval_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$var1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

     <div class="example-contents"><p>以上例程会输出：</p></div>
     <div class="example-contents screen">
<div class="cdata"><pre>
string(11) &quot;Hello World&quot; refcount(2)
</pre></div>
     </div>
    </div>
   </p>
   <p class="para">
    Although <var class="varname">$var1</var>, <var class="varname">$var2</var>, and
    <var class="varname">$var3</var> are linked as references, only the
    <em class="emphasis">value</em> is passed to <span class="function"><strong>debug_zval_dump()</strong></span>.
    That value is used once by the set of references, and once inside the
    <span class="function"><strong>debug_zval_dump()</strong></span>, so shows a refcount of 2.
   </p>
   <p class="para">
    Further complications arise because of optimisations made in the engine for
    different data types. Some types such as integers do not use &quot;copy on write&quot;,
    so do not show a refcount at all. In other cases, the refcount shows extra
    copies used internally, such as when a literal string or array is stored as
    part of a code instruction.
   </p>
  </p></blockquote>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.debug-zval-dump-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.var-dump.html" class="function" rel="rdfs-seeAlso">var_dump()</a> - 打印变量的相关信息</span></li>
    <li class="member"><span class="function"><a href="function.debug-backtrace.html" class="function" rel="rdfs-seeAlso">debug_backtrace()</a> - 产生一条回溯跟踪(backtrace)</span></li>
    <li class="member"><a href="language.references.html" class="link">References Explained</a></li>
    <li class="member"><a href="http://derickrethans.nl/php_references_article.php" class="link external">&raquo;&nbsp;References Explained (by Derick Rethans)</a></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>